﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 手牌管理类
/// </summary>
public class HandCardManager : MonoBehaviour
{
    public List<CardUI> handcards = new List<CardUI>();
    public GameObject cardUIPrefab;
    void Start()
    {

    }

    void Update()
    {

    }
    /// <summary>
    /// 添加一张手牌入手
    /// </summary>
    /// <param name="cardAttr"></param>
    public void AddOneCardInHand(CardBase cardAttr)
    {
        GameObject newCardObj = GameObject.Instantiate(cardUIPrefab, GameObject.Find("handCard").transform);
        newCardObj.GetComponent<CardUI>().cardUIInit(cardAttr);
    }

    public void RemoveOneCardFromHand(CardBase cardAttr){
        for(int i = handcards.Count - 1; i >= 0;i--){
            if(cardAttr == handcards[i].getCardAttr()){
                CardUI temp = handcards[i];
                handcards.Remove(temp);
                Destroy(temp.gameObject);
            }

        }
    }

}
